package com.wangshouyu.mp.template;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import com.wangshouyu.mp.miniprogram.Miniprogram;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 王守钰
 * @date 2020年12月19日 06:47
 * @description 模板消息
 */
public class TemplateMessage<T> implements Serializable {

    /**
     * 接收者openid
     */
    @SerializedName(value = "touser")
    @JsonProperty(value = "touser")
    @JSONField(name = "touser")
    private String toUser;

    /**
     * 模板ID
     */
    @SerializedName(value = "template_id")
    @JsonProperty(value = "template_id")
    @JSONField(name = "template_id")
    private String templateId;

    /**
     * 模板跳转链接
     */
    private String url;

    /**
     * 跳小程序所需数据
     */
    private Miniprogram miniprogram;

    /**
     * 模板数据
     */
    private T data;

    public String getToUser() {
        return toUser;
    }

    public void setToUser(String toUser) {
        this.toUser = toUser;
    }

    public String getTemplateId() {
        return templateId;
    }

    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Miniprogram getMiniprogram() {
        return miniprogram;
    }

    public void setMiniprogram(Miniprogram miniprogram) {
        this.miniprogram = miniprogram;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TemplateMessage<?> that = (TemplateMessage<?>) o;
        return Objects.equals(toUser, that.toUser) && Objects.equals(templateId, that.templateId) && Objects.equals(url, that.url) && Objects.equals(miniprogram, that.miniprogram) && Objects.equals(data, that.data);
    }

    @Override
    public int hashCode() {
        return Objects.hash(toUser, templateId, url, miniprogram, data);
    }


}
